const fs=require('fs');
const path=require('path');

let login = async (ctx, next) => {
    let data = fs.readFileSync(path.join(path.resolve(__dirname,'..'),'../login.html'));
    ctx.response.body = data.toString();
    await next();
};

let toLogin = async (ctx, next) => {
    let username = ctx.request.body.username;
    let password = ctx.request.body.password;
    ctx.response.body = `欢迎您${username}登录成功！！！`;
    // console.log(`欢迎您${username}登录成功！！！`);
    console.log(`${username}`);
    console.log(`${password}`);
    await next();
};

module.exports = {
    'GET/login': login,
    'POST/toLogin': toLogin
};